<?php

class RendererConfiguration {

	var $aProperties;

	function RendererConfiguration () {
		
		$this->_AddProperty( 'ShowColumns',          			true, 'BOOLEAN' );
		$this->_AddProperty( 'ShowForeignKeys',          		true, 'BOOLEAN' );
		$this->_AddProperty( 'ShowForeignKeysToFilteredTables', true, 'BOOLEAN' );
	}

	function _AddProperty( $sPropertyName, $xDefaultValue, $sType = 'GENERIC' ) {

		$sClassName = 'Datatype_' . $sType;
		if ( !class_exists( $sClassName ) ) {
			$sClassName = 'Datatype_Generic';	
		}

		$this->aProperties[ $sPropertyName ] = new $sClassName( $sPropertyName, $xDefaultValue );
	}

	function GetProperty( $sPropertyName ) {
		if ( isset( $this->aProperties[ $sPropertyName ] ) ) {
			$oProperty =& $this->aProperties[ $sPropertyName ];
			return $oProperty->GetValue();
		}
		return false;
	}

	function SetProperty( $sPropertyName, $xPropertyValue ) {
		if ( isset( $this->aProperties[ $sPropertyName ] ) ) {
			$oProperty =& $this->aProperties[ $sPropertyName ];
			$oProperty->SetValue( $xPropertyValue );
		}
	}
	
	function GetType() {
		return get_class( $this );
	}
	
	function GetXmlElement() {
		$oElement = new XmlElement( $this->GetType() );
		foreach( $this->aProperties as $oThisProperty ) {
			$oElement->AddElement( $oThisProperty->GetXmlElement() );
		}
		return $oElement;
	}
	
	// TODO: WIP
	// TODO: Move this into a new class structure...

	function GetHtml() {
		$sHtml = '<p><h3>'.get_class( $this ).'</h3>';
		foreach( $this->aProperties as $oThisProperty ) {
			$sHtml .= $oThisProperty->GetHtml( get_class( $this ) );
		}
		$sHtml .= '</p>';
		return $sHtml;
	}
}

require_once( 'Classes/Datatypes/Datatype_Generic.php' );
require_once( 'Classes/Datatypes/Datatype_Boolean.php' );
require_once( 'Classes/Datatypes/Datatype_String.php' );
require_once( 'Classes/Datatypes/Datatype_Integer.php' );

?>
